package Image;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.22.19.59
 */
public class Img3 {
    public static void main(String[] args) throws IOException {
        var w=500;
        var h=500;
        var t=2;
        var i=new BufferedImage(w,h,t);
        var g=i.createGraphics();
        //
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
        g.setStroke(new BasicStroke(5));
        g.setColor(Color.GRAY);
        g.fillRect(0,0,w,h);

        g.draw3DRect(15,15,100,100,true);
        g.draw3DRect(135,135,100,100,false);

        g.setColor(Color.BLUE);
        Polygon p=new Polygon();
        p.addPoint(50,10);
        p.addPoint(90,150);
        p.addPoint(20,350);
        g.drawPolygon(p);
//画圆 椭圆
        g.setColor(Color.PINK);
        g.drawOval(300,300,50,50);
        g.fillOval(200,400,100,100);
//扇形，圆弧
        g.fillArc(250,250,100,100,0,45);


        g.dispose();
        ImageIO.write(i,"png",new File("i1.png"));
    }
}
